package com.scloud.scloudextends.sigar;

import com.scloud.scloudextends.vo.CpuVO;
import com.scloud.scloudextends.vo.MemoryVO;
import lombok.extern.slf4j.Slf4j;
import org.hyperic.sigar.SigarException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class SigarController {

    @GetMapping("/cpu")
    public CpuVO getCpuData() {
        try {
            return SigarLocalDeviceDataAcquisition.getCpu();
        } catch (SigarException e) {
            e.printStackTrace();
            return null;
        }
    }

    @GetMapping("/memory")
    public MemoryVO getMemory() {
        try {
            return SigarLocalDeviceDataAcquisition.getMemory();
        } catch (SigarException e) {
            e.printStackTrace();
            return null;
        }
    }
}